//引入uuid
import { v4 as uuidv4 } from 'uuid';
//暴露一个默认函数
export default function getUserTempId() {
  //获取本地的id
  let userTempId = localStorage.getItem("userTempId");
  //如果id存在则返回id
  if (userTempId) return userTempId;
  //如果id不存在则生成id
  userTempId = uuidv4();
  //并添加到本地存储
  localStorage.setItem("userTempId", userTempId);
  //然后将数据返回出去
  return userTempId;
}
